package br.com.comanda.customadapters;

import java.util.List;

import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;
import br.com.comanda.R;
import br.com.comanda.vos.Account;
import br.com.comanda.vos.Product;

public class ProductAdapter extends ArrayAdapter<Product> {

	/*
	 * Used to instantiate layout XML file into its corresponding View objects
	 */
	private final LayoutInflater inflater;

	/*
	 * each list item layout ID
	 */
	private final int resourceId;

	public ProductAdapter(Context context, int resource, List<Product> objects) {
		super(context, resource, objects);
		this.inflater = LayoutInflater.from(context);
		this.resourceId = resource;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final Product product = getItem(position);

		convertView = this.inflater.inflate(this.resourceId, parent, false);

		TextView productName = (TextView) convertView.findViewById(R.id.tvProductName);
		TextView description = (TextView) convertView.findViewById(R.id.tvDescription);

		TextView price = (TextView) convertView.findViewById(R.id.tvPrice);

	

		productName.setText(product.getName());
		description.setText(product.getDescription());
		price.setText("R$"+product.getPrice());

		return convertView;
	}
}
